<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('room-types', 'RoomTypeController@list')->name('roomTypes');

/**
 * Customer Login Routers
 */
Route::get('login', 'LoginController@showLoginForm')->name('showLogin');
Route::post('login', 'LoginController@login')->name('login');
Route::get('register', 'RegisterController@showRegistrationForm')->name('showRegister');
Route::post('register', 'RegisterController@register')->name('register');
Route::post('logout', 'LoginController@logout')->name('logout');

Route::middleware('auth:customer')->group(function(){
    Route::get('profile', 'CustomerController@displayProfile')->name('showProfile');
    Route::post('profile', 'CustomerController@profile')->name('profile');
    Route::get('change-password', 'CustomerController@showChangePasswordForm')->name('changePassword');
    Route::post('change-password', 'CustomerController@changePassword')->name('change-password');
    /* Room and Orders */
    Route::get('search-room-types', 'AvailabilityController@searchRoomType')->name('searchRoomTypes');
    Route::get('order', 'OrderController@create')->name('showPreOrderForm');
    Route::post('order', 'OrderController@order')->name('preOrder');
    // display change order form
    Route::get('change-order', 'OrderController@edit')->name('showChangeOrderForm');
    Route::post('change-order', 'OrderController@update')->name('changeOrder');
    // delete/cancel order
    Route::get('delete-order', 'OrderController@delete')->name('deleteOrder');
    // list orders
    Route::get('orders', 'OrderController@index')->name('orders');
    // list bookings
    Route::get('bookings', 'BookingController@index')->name('bookings');
    Route::middleware('payinfo')->group(function(){
        // save order request
        Route::get('save-order', 'OrderController@store')->name('saveOrder');
        Route::get('order-success', 'OrderController@success')->name('orderSuccess');
        /* payments */
        Route::get('pay', 'PaymentController@showPayForm')->name('showPayForm');
        Route::get('cancel-pay', 'PaymentController@cancel')->name('cancelPay');
        Route::post('pay', 'PaymentController@pay')->name('pay');
    });
});

Route::get('home', 'CustomerController@index')->name('home');

Route::get('/', function () {
    return redirect('/home');
});
